quic: add proper error codes & messages for QUIC failures#63198
quic: add proper error codes & messages for QUIC failures#63198pimterry wants to merge 6 commits into
Conversation
|
Review requested:
|
31b4709 to
aefee4f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63198 +/- ##
==========================================
- Coverage 91.68% 90.32% -1.36%
==========================================
Files 361 730 +369
Lines 156230 234688 +78458
Branches 24021 43939 +19918
==========================================
+ Hits 143232 211990 +68758
- Misses 12729 14411 +1682
- Partials 269 8287 +8018
🚀 New features to boost your workflow:
|
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
this is a great change.
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
this is a great change.
Signed-off-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
40eebfd to
60b6e3b
Compare
|
Updated to use bindingdata, rebased and force pushed because we need to update the test from #63193 (just merged) as well since that asserted on the error message. |
Qard
left a comment
There was a problem hiding this comment.
Is there some reason you're undid the use of the existing core errors system? Shouldn't we be keeping that?
| function makeQuicError(code, prefix, type, errorCode, reason, errorName) { | ||
| const err = new QuicError( | ||
| quicErrorMessage(prefix, errorCode, reason, errorName), | ||
| { errorCode, code, type }); | ||
| if (reason) err.reason = reason; | ||
| if (errorName) err.errorName = errorName; | ||
| return err; | ||
| } |
There was a problem hiding this comment.
Should we not keep the same error construction mechanism as the others? We lose a bunch of things by not using that. Not sure we should be taking these out of the global errors set.
There was a problem hiding this comment.
This was a suggestion here, changed here.
We still use standard error codes, but we use a single QuicError class instead of the standard construction of per-code error classes: https://github.com/nodejs/node/blob/main/doc/api/quic.md#class-quicerror. This error class is used by users as well to control QUIC error behaviour, and this approach gives us consistent errors for every kind of failure at the protocol level. I don't feel strongly about it myself, but it seemed like a reasonable suggestion and having a single QUIC error class is tidy.
What do we lose by not using the standard error mechanism vs this setup?
There was a problem hiding this comment.
We lose the hideStackFrames logic, which means we'll see a bunch more internals things in stack traces here which we might not want to surface, like every validator gains a stack line without this. I'm not against this change, but just want to be sure that special-casing this is acceptable.
There was a problem hiding this comment.
In this case, I think the previous code didn't do this either - our validators do hide internal stack traces, but AFAICT the normal error code definitions don't do this unless you use HideStackFramesError explicitly.
It is easy to do though, and I agree it'd be a nice improvement - I've just pushed a commit that adds ErrorCaptureStackTrace(err, makeQuicError) here, which will omit these internal bits from the stack in the same way. This mirrors the equivalent setup for custom errors elsewhere like
Lines 350 to 363 in 92f48f4
Is that what you were looking for?
This wraps QUIC errors, providing useful error codes and messages for the defined error code cases from both OpenSSL and ngtcp2.
Before this, QUIC errors looked like:
Now they look like: